//获取 
function getData(key) {
    var collection = localStorage.getItem(key);
    if (collection != null) {
        return JSON.parse(collection);
    } else {
        return [];
    }
}

//   清空
function delData() {
    localStorage.clear();
}

//   存储
function setData(key, data) {
    localStorage.setItem(key, JSON.stringify(data));
}